package com.gandong8.derby.controller;

import com.gandong8.derby.core.util.RequestUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Objects;
/**
 * 公共控制层
 * @author xiaoyutou
 */
abstract class BaseController {

    protected HttpServletRequest getHttpServletRequest() {
        return RequestUtil.getRequest();
    }

    protected HttpServletResponse getHttpServletResponse() {
        return RequestUtil.getResponse();
    }

    protected HttpSession getSession() {
        return Objects.requireNonNull(RequestUtil.getRequest()).getSession();
    }

    protected HttpSession getSession(Boolean flag) {
        return Objects.requireNonNull(RequestUtil.getRequest()).getSession(flag);
    }

    protected String getPara(String name) {
        return Objects.requireNonNull(RequestUtil.getRequest()).getParameter(name);
    }
}
